import javax.xml.soap.Node;

public class O53II {
    public static void main(String[] args) {
        O53II o = new O53II();
        System.out.println(o.missingNumber(new int[]{0,1,2,4,5,6,7,8,9}));
    }
    public int missingNumber(int[] nums) {
        if (nums[0]!=0)
            return 0;
        int mid = nums.length/2;
        int l = 0,r=nums.length;
        while (l<r){
            if (nums[mid]>mid)
                r = mid-1;
            else
                l = mid+1;
            mid = (l+r)/2;
        }
        if (mid==nums.length)
            return nums.length;
        if (nums[mid]!=mid)
            return mid;
        return mid+1;
    }

}
